/**
 * @description  交易所基础信息（债券指令）
 * @author shenhong
 */
import { Form } from '@ant-design/compatible';

import '@ant-design/compatible/assets/index.css';
import { connect } from 'dva';
import React, { PureComponent } from 'react';

import { DATA_ENTRY, codeType, FormGroup } from '../../../../../comps';
import { isZiGuanEvir, calculateFee } from '../../../../../utils/commonFunc';
import investmentType from '../../../../../utils/enumeratedValues/investmentType';
import style from '../index.less';

@Form.create()
class BasicInfoZQ extends PureComponent {
  // eslint-disable-next-line react/static-property-placement
  static defaultProps = {
    onRef: () => {},
    portfolioOnChange: () => {},
    tradingcodeOnChange: () => {},
  };

  constructor() {
    super();
    this.state = {
      buyBackMoney: undefined, // 回购金额
      buyBackRate: undefined, // 回购利率
      occupationDays: undefined, // 实际占款天数
      isDisabled: false, // 详情和交收时表单全部置灰
      showRate: true, // 是否展示买入收益率和买入行权收益率
      price: undefined, // 计算金额时使用的价格
      num: undefined, // 计算金额时使用的数量
      SecuritiesCode: undefined, // 计算买入收益率和买入行权收益率用的证券代码相关数据
      bussniessVisible: false, // 业务目标编辑补充是否可见
      SPPI_result: undefined, // 根据证券代码获取sppi结果
      objectives: undefined, // 选中的业务目标
      objectivesEditObj: {}, // 缓存每一个业务目标对应的编辑
      editContent: {}, // 业务目标编辑内容
      investmentTypeList: [...investmentType], // 投资类型下拉
      tradeDirect: '1', // 交易方向
      isZiGuan: false,
      feeData: {
        // 费用自动计算条件
        productId: undefined,
        portfolioid: undefined,
        tradingCode: undefined,
        exchangecode: undefined,
        trademarket: 'jjpt',
        sectype: 'bond',
        orderside: undefined,
        price: undefined,
      },
    };
  }

  componentDidMount() {
    this.props.onRef(this);
    if (this.props.type == '3' || this.props.type == '4') {
      // 详情时取业务目标的值
      this.setState({
        objectives: this.props.info && this.props.info.trade0 ? this.props.info.trade0.bussinessObjectives : undefined,
        editContent: this.props.info.trade0 ? this.props.info.trade0 : {},
      });
      this.props.dispatch({
        type: 'bondDeviationDetailM/queryBondBasicInfoDetail',
        payload: {
          secucode: this.props.info?.trade0.securityId.split('-')[0],
        },
        callback: () => {},
      });
    }
    const temp = isZiGuanEvir();
    const isZiGuan = !!temp; // 判断该页面是在资管被引入的，还是maat
    this.setState({ isZiGuan });
  }

  // 清空表单
  // eslint-disable-next-line react/no-unused-class-component-methods
  reset = () => {
    const { form } = this.formGroupThis.props;
    form.resetFields();
    this.setState({
      buyBackMoney: undefined, // 回购金额
      buyBackRate: undefined, // 回购利率
      occupationDays: undefined, // 实际占款天数
      isDisabled: false, // 详情和交收时表单全部置灰
      showRate: true, // 是否展示买入收益率和买入行权收益率
      price: undefined, // 计算金额时使用的价格
      num: undefined, // 计算金额时使用的数量
      SecuritiesCode: undefined, // 计算买入收益率和买入行权收益率用的证券代码相关数据
      bussniessVisible: false, // 业务目标编辑补充是否可见
      SPPI_result: undefined, // 根据证券代码获取sppi结果
      objectives: undefined, // 选中的业务目标
      objectivesEditObj: {}, // 缓存每一个业务目标对应的编辑
      editContent: {}, // 业务目标编辑内容
      investmentTypeList: [...investmentType], // 投资类型下拉
      tradeDirect: '1', // 交易方向
    });
  };

  // 费用自动计算
  changeFee = (type, data) => {
    const {
      form: { setFieldsValue },
    } = this.formGroupThis.props;
    if (this.props.type == 3 || this.props.type == 4) return; // 详情不计算
    setTimeout(() => {
      // 产品切换清空组合时，不调用费用接口
      if (data == undefined) {
        setFieldsValue({ fee: undefined });
        if (type == 'tradingCode') {
          this.setState({ feeData: { ...this.state.feeData, tradingCode: undefined, exchangecode: undefined } });
        } else if (type == 'productId') {
          this.setState({ feeData: { ...this.state.feeData, productId: undefined, portfolioid: undefined } });
        } else {
          this.setState({ feeData: { ...this.state.feeData, [type]: undefined } });
        }
      } else if (type == 'tradingCode') {
        this.setState({ feeData: { ...this.state.feeData, tradingCode: data.tradingCode, exchangecode: data.exchangeCode } }, () => {
          const fee = calculateFee(this.state.feeData);
          fee.then((r) => {
            setFieldsValue({ fee: r });
          });
        });
      } else {
        this.setState({ feeData: { ...this.state.feeData, [type]: data } }, () => {
          const fee = calculateFee(this.state.feeData);
          fee.then((r) => {
            setFieldsValue({ fee: r });
          });
        });
      }
    }, 100);
  };

  // 交易方向改变执行方法
  changeDirect = (e) => {
    this.setState(
      {
        tradeDirect: e.value,
      },
      () => {
        if (this.props.type < 3) {
          // 交易方向改变 对投资类型的影响 1买入 2卖出
          this.setSelectList();
        }
        if (e) {
          if (e.value == '1') {
            // 交易方向为买入时展示买入收益率/买入行权收益率
            const flag = this.state.showRate;
            this.setState(
              {
                showRate: true,
              },
              () => {
                if (!flag) {
                  this.getRata();
                }
              },
            );
          } else {
            if (e.value == '4') {
              // 交易方向为债回售时清空价格，金额
              const {
                form: { setFieldsValue },
              } = this.formGroupThis.props;
              if (this.props.info) {
                // 详情页面展示金额
                setFieldsValue({
                  fullPrice: undefined,
                });
              } else {
                setFieldsValue({
                  fullPrice: undefined,
                  amount: undefined,
                });
                this.changeFee('price', undefined);

                this.setState({
                  price: undefined,
                });
                this.getSPPI_Result(); // 清空sppi结果 和 校验投资类型值
              }
            }
            this.setState({ showRate: false });
          }
        }
      },
    );
  };

  // 获取买入收益率
  getRata = () => {
    const { dispatch, businessType } = this.props;
    const {
      form: { setFieldsValue },
    } = this.formGroupThis.props;
    const { SecuritiesCode, price } = this.state;
    if (this.props.info) return;
    if (SecuritiesCode !== null && SecuritiesCode !== undefined && price !== undefined && price != 0) {
      dispatch({
        // 获取买入收益率/买入行权收益率
        type: 'bondTradeM/getRate',
        payload: {
          tradingcode: SecuritiesCode.tradingCode,
          exchangeCode: SecuritiesCode.exchangeCode,
          price,
          type: businessType,
        },
        callback: (res) => {
          const { data } = res;
          setFieldsValue({
            yield: data.yield, // 回填买入收益率/买入行权收益率
            exerciseYield: data.exerciseYield,
          });
        },
      });
    } else {
      // 清空买入收益率/买入行权收益率
      setFieldsValue({
        yield: '',
        exerciseYield: '',
      });
    }
  };

  // 价格改变事件
  fullPrice = (e) => {
    const { num, SecuritiesCode } = this.state;
    const {
      form: { setFieldsValue },
    } = this.formGroupThis.props;
    const {
      bondDeviationDetailM: { isConvertibleBond = false },
    } = this.props;
    this.setState(
      {
        price: typeof e == 'number' ? e : undefined, // 把价格放入state方便数量改变时取值使用
      },
      () => {
        if (typeof e == 'string') return; // 当值为123B  这样的数据不请求
        if (typeof e == 'number') {
          this.getRata(); // 获取买入收益率/买入行权收益率
        }
        this.getSPPI_Result(); // 清空sppi结果 和 校验投资类型值
        if (typeof e == 'number') {
          if (num !== undefined) {
            const money = parseFloat((num * e).toFixed(isConvertibleBond && SecuritiesCode?.exchangeCode == '101' ? 2 : 3)); // 金额=数量*价格
            setFieldsValue({
              amount: money, // 回填金额
            });
            this.changeFee('price', money);
          }
        }
      },
    );
  };

  // 证券代码改变事件
  changePort = (e) => {
    const { type } = this.props;
    this.setState(
      {
        SecuritiesCode: e,
      },
      () => {
        if (type !== '3' && type !== '4') {
          this.getRata();
          this.getSPPI_Result();
        }
      }, // 获取买入收益率/买入行权收益率
      // eslint-disable-next-line function-paren-newline
    );
    if (e !== undefined && e !== null) {
      let text = '';
      if (e.exchangeCode == '101') {
        text = '1';
      } else if (e.exchangeCode == '113') {
        text = 'B';
      } else if (e.exchangeCode == '105') {
        text = '2';
      } else if (e.exchangeCode == '999') {
        text = 'cw';
      }
      this.formGroupThis.props.form.setFieldsValue({
        securityExchange: text,
      });
    } else {
      this.formGroupThis.props.form.setFieldsValue({
        securityExchange: '',
      });
    }
  };

  // 获取sppi结果
  getSPPI_Result = () => {
    const { SecuritiesCode, price } = this.state;
    const {
      form: { setFieldsValue },
    } = this.formGroupThis.props;
    if (this.props.type < 3) {
      if (SecuritiesCode && price != undefined) {
        // 证券代码和价格都不为空
        this.props.dispatch({
          type: 'bondTradeM/getSPPIResult',
          payload: {
            exchangeCode: SecuritiesCode.exchangeCode,
            tradingCode: SecuritiesCode.tradingCode,
            price,
          },
          callback: (data) => {
            let temp;
            if (data) {
              // sppi有值 不可点击新增按钮  无值可以
              temp = data.rgpd;
            } else {
              temp = undefined;
            }
            this.setState(
              {
                SPPI_result: temp,
              },
              () => {
                setFieldsValue({
                  SPPI_result: this.state.SPPI_result,
                });
                this.setSelectList();
              },
            );
          },
        });
      } else {
        // 证券代码和价格有一个为空 则清空sppi 并修改投资类型
        this.setState(
          {
            SPPI_result: undefined,
          },
          () => {
            setFieldsValue({
              SPPI_result: this.state.SPPI_result,
            });
            this.setSelectList();
          },
        );
      }
    }
  };

  // 设置投资类型下拉 并确定默认值
  setSelectList = () => {
    /**
     *     // 以收取该金融资产合同现金流量为目的  是  AC
     *     // 以收取该金融资产合同现金流量为目的  否  FVTPL
     *     // 以收取该合同现金流量及出售金融资产为目的  是  FVOCI
     *     // 以收取该合同现金流量及出售金融资产为目的  否  FVTPL
     *     // 其他  是 or 否  FVTPL
     */
    // eslint-disable-next-line camelcase
    const { SPPI_result, objectives, tradeDirect } = this.state;
    const {
      form: { setFieldsValue },
    } = this.formGroupThis.props;
    if (tradeDirect == '1') {
      // 交易方向为买入
      // eslint-disable-next-line camelcase
      if (SPPI_result == undefined || objectives == undefined) {
        setFieldsValue({
          investmentType: undefined,
        });
        this.setState({
          investmentTypeList: investmentType,
        });
        return;
      }
      let arr = [];
      // eslint-disable-next-line camelcase
      if (objectives == 1 && SPPI_result == 1) {
        // AC
        arr = [{ value: 'AC', title: 'AC' }];
        setFieldsValue({
          investmentType: 'AC',
        });
        // eslint-disable-next-line camelcase
      } else if ((objectives == 1 && SPPI_result == 2) || (objectives == 2 && SPPI_result == 2) || (objectives == 4 && SPPI_result)) {
        // FVTPL
        arr = [{ value: 'FVTPL', title: 'FVTPL' }];
        setFieldsValue({
          investmentType: 'FVTPL',
        });
        // eslint-disable-next-line camelcase
      } else if (objectives == 2 && SPPI_result == 1) {
        // FVOCI
        arr = [{ value: 'FVOCI', title: 'FVOCI' }];
        setFieldsValue({
          investmentType: 'FVOCI',
        });
      } else {
        arr = [...investmentType];
        setFieldsValue({
          investmentType: undefined,
        });
      }
      this.setState({
        investmentTypeList: [...arr],
      });
    } else if (tradeDirect == '2') {
      // 交易方向卖出 请求新的接口
      this.setState({
        investmentTypeList: [...investmentType],
      });
      setFieldsValue({
        investmentType: this.props.investmentType,
      });
    }
  };

  // 数量改变事件
  changeorderQty = (e) => {
    const { price, SecuritiesCode } = this.state;
    const {
      form: { setFieldsValue, getFieldsValue },
    } = this.formGroupThis.props;
    const {
      bondDeviationDetailM: { isConvertibleBond = false },
    } = this.props;
    this.setState({
      num: typeof e == 'number' ? e : undefined,
    });
    if (price !== undefined && typeof e == 'number') {
      if (getFieldsValue().orderSide == '4') return; // 债回售 不做计算
      const money = parseFloat((e * price).toFixed(isConvertibleBond && SecuritiesCode?.exchangeCode == '101' ? 2 : 3)); // 金额=数量*价格
      setFieldsValue({
        amount: money, // 回填金额
      });
      this.changeFee('price', money);
    }
  };

  // 业绩目标修改
  changeObjectives = (e) => {
    this.setState(
      {
        objectives: e,
      },
      () => {
        this.setSelectList();
      },
    );
  };

  // 表单内容
  formContent = () => {
    const {
      info,
      type,
      businessType,
      isSecondShow,
      listId,
      bondDeviationDetailM: { isConvertibleBond = false },
      globalM: {
        dataDictionary: { SPPI_USER_DEFINEDTYPE = [] },
      },
    } = this.props;
    const securityIdVal = info && info.trade0 && info.trade0.securityId ? `${info.trade0.securityId.split('-')[1]}-${info.trade0.securityId.split('-')[2]}` : undefined;
    const {
      // eslint-disable-next-line camelcase
      showRate,
      SPPI_result,
      SecuritiesCode,
      investmentTypeList,
      isZiGuan,
      tradeDirect,
    } = this.state;
    const direct = [
      { value: '1', title: '买入' },
      { value: '2', title: '卖出' },
    ];
    const tenant = localStorage.getItem('antd-pro-tenant');
    return (
      <FormGroup
        dataSource={[
          type == '10'
            ? {
                dataIndex: 'listId',
                type: DATA_ENTRY.SERIESPRODUCTGROUP,
                rules: [{ required: true, message: '请选择系列产品!' }],
                disabled: true,
                initialValue: listId,
                onChange: (e) => {
                  if (e) {
                    this.props.seriesProductsOnChange(e.value); // 向外抛处系列产品id
                  } else {
                    this.props.seriesProductsOnChange(undefined); // 向外抛处系列产品id
                  }
                },
                span: 24,
              }
            : {
                dataIndex: ['productId', 'portfolioId'],
                type: DATA_ENTRY.PRODUCTGROUPSEP,
                multipleGroup: false,
                initialValue: type == '3' || type == '4' ? (isSecondShow ? [info.productId, info.portfolioId] : [info.portfolioInfoId, info.productId]) : undefined,
                disabled: type == '3',
                rules: [[{ required: true, message: '请选择产品!' }], [{ required: true, message: '请选择组合!' }]],
                groupOnChange: (e) => {
                  if (e) {
                    this.props.portfolioOnChange(e.key); // 向外抛处组合id
                    this.props.portfolioCode(e.info.portfolioCode); // 向外抛出组合code
                    this.changeFee('portfolioid', e.key);
                  } else {
                    this.props.portfolioOnChange(undefined); // 向外抛处组合id
                    this.props.portfolioCode(undefined); // 向外抛出组合code
                    this.changeFee('portfolioid', undefined);
                  }
                },
                productOnChange: (e) => {
                  if (e) {
                    this.props.productCode(e.info.portfolioCode); // 向外抛出产品code
                    this.changeFee('productId', e.key);
                  } else {
                    this.props.productCode(undefined); // 向外抛出产品code
                    this.changeFee('productId', undefined);
                  }
                },
                positionBody: true,
                authority: 'write', // 可写权限
                exist: 1,
                span: 24,
                tradeModel: type == 1 || type == 2 ? ['BOOKKEEPING_MODE', 'COMMAND_MODE'] : undefined, // 不包含估值解析和估值对接的产品
              },
          {
            dataIndex: 'securityId',
            type: DATA_ENTRY.SECURITIESCODE,
            title: '证券代码',
            initialValue: type == 3 ? securityIdVal : '',
            codeType: codeType.zq,
            disabled: type == '3',
            queryItems: { exchangeCode: '101,105' }, // 101-深交所，105-上交所
            onChange: (e) => {
              console.log(e, 'zzz');
              this.changePort(e);
              if (e) {
                this.props.tradingcodeOnChange(e);
                this.changeFee('tradingCode', e);
              } else {
                this.props.tradingcodeOnChange(undefined);
                this.changeFee('tradingCode', undefined);
              }
            },
            rules: [{ required: true, message: '请选择证券代码!' }],
            span: 12,
            positionBody: true,
          },
          {
            title: '交易市场',
            type: DATA_ENTRY.TRADINGMARKET,
            dataIndex: 'securityExchange',
            dataType: 2,
            disabled: true,
            initialValue: type == '3' ? info.trade0.securityExchange : '',
            rules: [{ required: true, message: '请选择交易所!' }],
            span: 12,
            onRef: (ref) => (this.formGroupThis = ref),
          },
          type == '10'
            ? {
                dataIndex: 'orderSide',
                type: DATA_ENTRY.SELECT,
                title: '委托方向',
                rules: [{ required: true, message: '请选择交易方向!' }],
                multiple: false,
                disabled: type == 3,
                initialValue: type == '3' || type == '4' ? info.trade0.orderSide : '1',
                placeholder: '请选择',
                onChange: (e) => {
                  if (!e) return;
                  this.changeDirect({ value: e });
                },
                dataSource: direct,
                span: 12,
              }
            : {
                dataIndex: 'orderSide',
                type: DATA_ENTRY.TRADINGDIRECT,
                rules: [{ required: true, message: '请选择交易方向!' }],
                multiple: false,
                disabled: type == 3,
                businessType,
                initialValue: type == '3' || type == '4' ? info.trade0.orderSide : '1',
                placeholder: '请选择',
                onChange: (e) => {
                  this.changeDirect(e);
                  this.changeFee('orderside', e.value);
                },
                allowClear: false,
                span: 12,
              },
          {
            // 交易类型
            dataIndex: 'orderType',
            type: DATA_ENTRY.TRADINGTYPE,
            rules: [{ required: true, message: '请选择交易类型!' }],
            initialValue: type == '3' || type == '4' ? info.trade0.orderType : '2',
            multiple: false,
            disabled: true,
            placeholder: '请选择',
            span: 12,
          },
          {
            title: '价格',
            dataIndex: 'fullPrice',
            type: DATA_ENTRY.INPUTNUMBER,
            placeholder: '请输入',
            min: 0,
            // eslint-disable-next-line max-len
            precision:
              type == '3' || type == '4' ? (isConvertibleBond && info.trade0.securityExchange == '1' ? 2 : 3) : isConvertibleBond && SecuritiesCode?.exchangeCode == '101' ? 2 : 3,
            initialValue: type == '3' ? info.trade0.price : undefined,
            splitStyle: true,
            disabled: type == '3' || type == '4' ? true : tradeDirect == '4',
            onChange: this.fullPrice,
            rules: [{ required: tradeDirect != '4', message: `请输入价格` }],
            unit: '元',
            span: 12,
            helper: SecuritiesCode?.exchangeCode == '105' ? '次级资产支持证券、上市公司发行的可转换公司债券为全价，其余为净价。' : '',
          },
          {
            title: '数量',
            dataIndex: 'orderQty',
            type: DATA_ENTRY.INPUTNUMBER,
            placeholder: '请输入数量',
            min: 10,
            precision: 0,
            splitStyle: true,
            initialValue: type == '3' || type == '4' ? info.trade0.orderQty : undefined,
            disabled: type == '3',
            onChange: this.changeorderQty,
            rules: [{ required: true, message: `请输入数量` }],
            unit: '张',
            span: 12,
          },
          {
            title: '金额',
            dataIndex: 'amount',
            type: DATA_ENTRY.INPUTNUMBER,
            placeholder: '请输入',
            min: 0,
            // eslint-disable-next-line max-len
            precision:
              type == '3' || type == '4' ? (isConvertibleBond && info.trade0.securityExchange == '1' ? 2 : 3) : isConvertibleBond && SecuritiesCode?.exchangeCode == '101' ? 2 : 3,
            splitStyle: true,
            initialValue: type == '3' || type == '4' ? info.trade0.amount : undefined,
            disabled: true,
            rules: [{ required: tradeDirect != '4', message: `请输入金额` }],
            unit: '元',
            span: 12,
          },
          ...(showRate
            ? [
                {
                  title: '买入收益率',
                  dataIndex: 'yield',
                  type: DATA_ENTRY.INPUTNUMBER,
                  placeholder: '请输入',
                  initialValue: type == '3' || type == '4' ? info.trade0.yield : '',
                  disabled: true,
                  precision: 2,
                  unit: '%',
                  span: 12,
                },
                {
                  title: '买入行权收益率',
                  dataIndex: 'exerciseYield',
                  type: DATA_ENTRY.INPUTNUMBER,
                  placeholder: '请输入',
                  initialValue: type == '3' || type == '4' ? info.trade0.exerciseYield : '',
                  disabled: true,
                  precision: 2,
                  unit: '%',
                  span: 12,
                },
              ]
            : []),
          {
            title: '费用',
            dataIndex: 'fee',
            type: DATA_ENTRY.INPUTNUMBER,
            placeholder: '请输入',
            min: 0,
            precision: 2,
            initialValue: type == '3' || type == '4' ? info.trade0.fee : '',
            splitStyle: true,
            disabled: !!(type == '3' || type == '4' || tradeDirect == '4'),
            unit: '元',
            span: 12,
            hide: type != 10, // 交易录入有费用
          },
          ...(type < 5 && !isZiGuan
            ? [
                {
                  // 业务目标
                  dataIndex: 'bussinessObjectives',
                  type: DATA_ENTRY.BUSINESSTARGETC,
                  disabled: !!(type == '3' || type == '4'),
                  initialValue: type == '3' || type == '4' ? info?.trade0?.bussinessObjectives : undefined,
                  onChangeFn: this.changeObjectives,
                  TaretType: type,
                  info: this.state.editContent,
                  getLayerValue: this.getObjectEdit,
                  span: 24,
                },
                {
                  dataIndex: 'SPPI_result',
                  type: DATA_ENTRY.SPPIRESULTC,
                  title: 'SPPI结果',
                  initialValue: type == '3' || type == '4' ? info.trade0.sppiResult : undefined,
                  selectProps: {
                    SecuritiesCode,
                    rightContentShow: type < 3, // 右侧按钮是否展示，后面展示后的禁用逻辑，展示逻辑，组件控制
                    // eslint-disable-next-line camelcase
                    SPPI_result, // 根据证券代码切换获取SPPI结果
                    SppItype: 3,
                    sppITitle: '新增测试',
                  },
                  onOk: this.getSPPI_Result, // 新增完了 重新获取结果
                  span: 12,
                },
                {
                  dataIndex: 'investmentType',
                  type: DATA_ENTRY.SELECT,
                  title: '投资类型',
                  disabled: type == '3' || type == '4' ? true : this.state.tradeDirect == 2,
                  initialValue: type == '3' || type == '4' ? info.trade0.investmentType : undefined,
                  dataSource: investmentTypeList,
                  span: 12,
                },
              ]
            : []),
          ...(type < 5 && tenant == 'XAYH' && !isZiGuan
            ? [
                {
                  dataIndex: 'userDefinedType',
                  type: DATA_ENTRY.SELECT,
                  title: '自定义分类',
                  disabled: !!(type == '3' || type == '4'),
                  initialValue: type == '3' || type == '4' ? info.trade0.userDefinedType : undefined,
                  dataSource: SPPI_USER_DEFINEDTYPE.map((item) => ({ value: item.code, title: item.value })),
                  span: 12,
                },
              ]
            : []),
          {
            dataIndex: 'remark',
            type: DATA_ENTRY.INPUT,
            title: '备注',
            disabled: !!(type == '3' || type == '4'),
            initialValue: type == '3' || type == '4' ? info.remark : '',
            placeholder: '请输入',
            showTextArea: true,
            autosize: { minRows: 2, maxRows: 2 },
            span: 24,
          },
        ]}
        autoLayout={false}
      />
    );
  };

  // 获取校验并获取表单的值
  // eslint-disable-next-line react/no-unused-class-component-methods
  getInfo = () => {
    const {
      form: { validateFields },
    } = this.formGroupThis.props;
    const { objectives, objectivesEditObj } = this.state;
    let query;
    const obj = objectivesEditObj[objectives];
    validateFields((err, fieldsValue) => {
      if (!err) {
        query = fieldsValue;
        query.sppiResult = query.SPPI_result; // 修改入参名
        if (this.props.type != 10) query.fee = 0; // 费用计算逻辑未完全梳理清楚，后续用户有真正需求时再添加费用计算相关逻辑
        delete query.SPPI_result;
        query.info = this.state.SecuritiesCode;
        if (obj) {
          query.editObj = { ...obj };
        }
      }
    });
    return query;
  };

  // 存储每一个业绩目标对应的补充编辑
  getObjectEdit = (objectivesEditObj) => {
    this.setState({
      objectivesEditObj,
    });
  };

  render() {
    return <div className={style.info}>{this.formContent()}</div>;
  }
}

export default connect(({ bondTradeM, globalM, bondDeviationDetailM }) => ({
  bondTradeM,
  globalM,
  bondDeviationDetailM,
}))(BasicInfoZQ);
